﻿#include<iostream>
#include<list>

void printList(const std::list<int>& L)
{
	for (std::list<int>::const_iterator it = L.begin(); it != L.end(); ++it)
	{
		std::cout << *it << " ";
	}
	std::cout << '\n';
}

void test01()
{
	std::list<int>L1;
	L1.push_back(10);
	L1.push_back(20);
	L1.push_back(30);
	L1.push_back(40);
	printList(L1);

	std::list<int> L2;
	L2 = L1;
	printList(L2);

	std::list<int> L3;
	L3.assign(++L2.begin(), --L2.end());
	printList(L3);

	std::list<int> L4;
	L4.assign(6,666);
	printList(L4);
}

void test02()
{

	std::list<int>L1;
	L1.push_back(10);
	L1.push_back(20);
	L1.push_back(30);
	L1.push_back(40);
	
	std::list<int> L2;
	L2.assign(6, 666);
	
	std::cout << "交换前：" << '\n';
	printList(L1);
	printList(L2);

	L1.swap(L2);
	std::cout << "交换后：" << '\n';
	printList(L1);
	printList(L2);

}

int main()
{
	//test01();
	test02();

	return 0;
}